package com.example.android.story.Utils;

import android.arch.persistence.room.Entity;
import android.arch.persistence.room.ForeignKey;
import android.arch.persistence.room.Index;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;

import cn.bmob.v3.BmobObject;

/**
 * Created by liwei on 2018/5/21.
 */

@Entity(tableName = "_purchased"
        ,indices = {@Index("username")}
        ,foreignKeys = {
        @ForeignKey(entity = Story.class,parentColumns = "title",childColumns = "story_title")
        ,@ForeignKey(entity = User.class,parentColumns = "username",childColumns = "username")
})
public class Purchased {
    @NonNull
    @PrimaryKey
    public String story_title;
    @NonNull
    public String username;

    public BmobObject getBmobObject(){
        PurchasedObj obj=new PurchasedObj();
        obj.setStoryTitle(this.story_title);
        obj.setUsername(this.username);
        return obj;
    }
    public class PurchasedObj extends BmobObject{
        private String storyTitle;
        private String username;

        public String getStoryTitle() {
            return storyTitle;
        }

        public void setStoryTitle(String storyTitle) {
            this.storyTitle = storyTitle;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }
    }
}
